<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Catalog</title>
</head>

<body background="../img/bg.jpg"> 
	<font face="Berlin Sans FB Demi" color="#357EC7" size="3">
<center>
	<?

include('auth.php');
require_once('/../config.php');
error_reporting (E_ALL ^ E_NOTICE);
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {die('Failed to connect to server: ' . mysql_error());}
           
$db = mysql_select_db(DB_DATABASE);
if(!$db) {die("Unable to select database");}

$profesor = $_SESSION['SESS_PROFNAME']; //editezi aici cu sesiunea
$fetch = mysql_fetch_array(mysql_query("SELECT * from profesori WHERE nume = '$profesor'"));
$sql = mysql_query("SELECT * FROM clase WHERE profesor_id='" . $fetch['id'] . "' GROUP BY nume");
?>
		<h1>Informatii profesor</h1>
		<table border=1>
			<tr>
				<td>Nume si prenume</td>
				<td><?php echo $fetch['nume']; ?></td>
			</tr>
           		<tr>
				<td>Clase unde preda</td>
				<td><?php
$rows = mysql_num_rows($sql);
$i=0;
while ($f =  mysql_fetch_array($sql))
{
	$i++;
	echo $f['nume'];
	if ($i!=$rows) echo ", ";
	
}
				?></td>
			</tr>
			<tr>
				<td>Diriginte la clasa</td>
				<td><?php echo $fetch['dirig']; ?></td>
			</tr>
		</table>
        	<br><a href="logout.php">Delogheaza-te</a>
			<br><a href="chpass.php">Schimba-ti parola</a>
			<br><br>
	
		<h1>Clase</h1>
        	<form method="post" action="clasa.php">
			<select name='clasa'>
<?php
$sql = mysql_query("SELECT * FROM clase WHERE profesor_id='" . $fetch['id'] . "' GROUP BY nume");
while($f = mysql_fetch_array($sql))
echo "				<option value='" . $f['nume'] . "'>" . $f['nume']  . "</option>\n";
echo '	<input type="hidden" name="prof" value="'.$profesor.'" />';
?>
			</select>
			<input type="submit" value="Vezi info.">
	
		</form>
        </font>
		</center>
</body>
</html>